package com.xiaoze.springcloud.entity;

/**
 * 登录用户上下文
 *
 * @author xiaoze
 * @date 2020/5/23
 */
public class UserInfoContext {

    private static final ThreadLocal<UserInfo> userInfoThreadLocal = new ThreadLocal<>();

    public static UserInfo getUser(){
        return userInfoThreadLocal.get();
    }

    public static void setUser(UserInfo user){
        userInfoThreadLocal.set(user);
    }

    public static void remove(){
        userInfoThreadLocal.remove();
    }

}
